package Servlet;

import com.cyy.bean.history;
import com.cyy.bean.record;
import com.cyy.dao.cartDao;
import com.cyy.dao.collectDao;
import com.cyy.dao.historyDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;

@WebServlet("/showUserBuyHistory")
public class showUserBuyHistoryServelt extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        System.out.println("开始展示用户购买日志！");
        historyDao historyDao=new historyDao();
        ArrayList<history> historys=null;
        try {
            historys = historyDao.selectAll();
        } catch (SQLException | ClassNotFoundException throwables) {
            throwables.printStackTrace();
        }
        if(historys!=null)
        {
            System.out.println(historys.get(0));
        }
        request.getSession().setAttribute("historys",historys);
        request.getRequestDispatcher("/salesmanUserHistory.jsp").forward(request,response);
    }


    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request,response);
    }
}
